<html><head><title>List.pb</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font><font color="#3A3966">;   PureBasic - Linked list example file
</font><font color="#3A3966">;
</font><font color="#3A3966">;    (c) Fantaisie Software
</font><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font>
<b><font color="#3A3966">Structure</font></b> BasicStructure 
    Field1.b
    Field2.w
    Field3.l
<b><font color="#3A3966">EndStructure</font></b>

<b><font color="#3A3966">Structure</font></b> ComplexStructure
    Field1.b
   *Basic.BasicStructure              <font color="#3A3966">; Pointer to a BasicStructure object
</font>    Basic2.BasicStructure             <font color="#3A3966">; Creation of the BasicStructure object inside this structure
</font>   *Next.ComplexStructure             <font color="#3A3966">; Pointer to another ComplexStructure object
</font><b><font color="#3A3966">EndStructure</font></b>

<b><font color="#3A3966">NewList</font></b> <font color="#3A3966">TestList</font>.BasicStructure()

<font color="#3A3966">;
</font><font color="#3A3966">;-------- Add Elements and TestLists --------
</font><font color="#3A3966">;
</font>
<font color="#3A3966">AddElement</font>(<font color="#3A3966">TestList</font>())
<font color="#3A3966">TestList</font>()\Field2 = 1

<font color="#3A3966">AddElement</font>(<font color="#3A3966">TestList</font>())
<font color="#3A3966">TestList</font>()\Field2 = 2

<font color="#3A3966">AddElement</font>(<font color="#3A3966">TestList</font>())
<font color="#3A3966">TestList</font>()\Field2 = 3

<font color="#3A3966">AddElement</font>(<font color="#3A3966">TestList</font>())
<font color="#3A3966">TestList</font>()\Field2 = 4

<font color="#3A3966">;
</font><font color="#3A3966">;-------- MessageRequester(&quot;Number of elements in the list:&quot;, Str(TestList()\Field2), 0) --------
</font><font color="#3A3966">;
</font>
<font color="#3A3966">MessageRequester</font>(&quot;Number of elements in the list:&quot;,<font color="#3A3966"> Str</font>(<font color="#3A3966">ListSize</font>(<font color="#3A3966">TestList</font>())), 0)

<font color="#3A3966">; First way to list all the elements
</font><font color="#3A3966">;
</font><font color="#3A3966">ResetList</font>(<font color="#3A3966">TestList</font>())               <font color="#3A3966">; Reset the list index before the first element.
</font>
<b><font color="#3A3966">While</font></b> <font color="#3A3966">NextElement</font>(<font color="#3A3966">TestList</font>())       <font color="#3A3966">; Process all the elements...
</font><font color="#3A3966">  MessageRequester</font>(&quot;List elements :&quot;, &quot;Field2 value : &quot;+<font color="#3A3966">Str</font>(<font color="#3A3966">TestList</font>()\Field2), 0)
<b><font color="#3A3966">Wend</font></b>

<font color="#3A3966">; Second way, with the help of ForEach
</font><font color="#3A3966">;
</font><b><font color="#3A3966">ForEach</font></b> <font color="#3A3966">TestList</font>()       <font color="#3A3966">; Process all the elements...
</font><font color="#3A3966">  MessageRequester</font>(&quot;List elements :&quot;, &quot;Field2 value : &quot;+<font color="#3A3966">Str</font>(<font color="#3A3966">TestList</font>()\Field2), 0)
<b><font color="#3A3966">Next</font></b>


<font color="#3A3966">SelectElement</font>(<font color="#3A3966">TestList</font>(), 2)  <font color="#3A3966">; Go directly to the 3rd element
</font><font color="#3A3966">MessageRequester</font>(&quot;3rd Element&quot;, &quot;Field2 value : &quot;+<font color="#3A3966">Str</font>(<font color="#3A3966">TestList</font>()\Field2), 0)


<font color="#3A3966">MessageRequester</font>(&quot;Linked List - Example&quot;, &quot;Finished&quot;, 0)

<b><font color="#3A3966">End</font></b>
</font></pre>
</body></html>
